//
//  BBItemCollectionCell.swift
//  BusinessBao
//
//  Created by Chen on 2017/7/19.
//  Copyright © 2017年 Chen. All rights reserved.
//

import UIKit
import SnapKit

class BBItemCollectionCell: UICollectionViewCell {
    
    var icon: UIImageView!
    var name: UILabel!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.contentView.isExclusiveTouch = true
        
        self.icon = UIImageView()
        self.icon.layer.cornerRadius = kRatio(number: 25)
        self.icon.clipsToBounds = true
        self.contentView.addSubview(self.icon)
        self.icon.snp.makeConstraints { (make) in
            make.width.height.equalTo(kRatio(number: 50))
            make.centerX.equalTo(self.contentView)
            make.top.equalTo(0)
        }
        
        self.name = UILabel()
        self.name.textColor = Import_Text_Color
        self.name.font = Font(font: kRatio(number: 12))
        self.name.textAlignment = .center
        self.contentView.addSubview(self.name)
        self.name.snp.makeConstraints { (make) in
            make.bottom.centerX.equalTo(self.contentView)
            make.height.equalTo(kRatio(number: 12))
            make.width.equalTo(kRatio(number: 60))
        }
    }
    
    func updateCell(data: Dictionary<String, String>) {
        self.icon.image = UIImage(named: data["iconName"]!)
        self.name.text = data["name"]
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
